<?
load_model('Common');
class Photo extends Common {
	protected $_name ="photo";
	protected $_primary = 'pho_id';
	
	public function get_phoclass_list(){
		$sql = "select a.*,b.class_name as class_fid_name from zf_class as a left join zf_class as b on a.class_fid=b.class_id where a.class_top=2 and a.class_fid<>0";
		$db = $this->getAdapter();
		return $db->fetchAll($sql);
	}
	
	public function get_phoclass_info($id){
		$db = $this->getAdapter();
		$where = $db->quoteInto('pho_class_id = ?', $id);
		return $this->fetchAll($where)->toArray();
	}
	//获取所有相片
	public function get_photo_list(){
		$arr = $this->fetchAll(null,"pho_id desc")->toArray();
		return $arr;
	}
	
	/**
	 *
	 * @param unknown_type $data
	 * @return 返回刚插入的id
	 */
	function add_pho($data){
		$dataInsert = array(
		    'pho_title' => $data['pho_title'],
		    'pho_lit_img'=> $data['pho_lit_img'],
		    'pho_big_img'=> $data['pho_big_img'],
		    'pho_class_id' => $data['pho_class_id'],
		   	'pho_date'	  => $data['pho_date'],
		);
		return $this->insert($dataInsert);
	}
	
	function update_pho($id, $data){
		$db = $this->getAdapter();
		$where = $db->quoteInto('pho_id = ?', $id);
		return $this->update($data, $where);
	}
	
	function del_pho($id){
		$db = $this->getAdapter();
		$where = $db->quoteInto('pho_id = ?', $id);
		return $this->delete($where);
	}
	
	
}

?>